<template>
  <div class="add-form">
    <el-dialog :visible.sync="showDiglog" title="题目预览" @close="close" width="60%" @open="open">
      <el-row>
        <el-col :span="6">【题型】：{{questionDetail.questionType|tx}}</el-col>
        <el-col :span="6">【编号】：{{questionDetail.id}}</el-col>
        <el-col :span="6">【难度】：{{questionDetail.difficulty|nd}}</el-col>
        <el-col :span="6">【标签】：{{questionDetail.tags}}</el-col>
        <el-col :span="6">【学科】：{{questionDetail.subjectName}}</el-col>
        <el-col :span="6">【目录】：{{questionDetail.directoryName}}</el-col>
        <el-col :span="6">【方向】：{{questionDetail.direction}}</el-col>
      </el-row>
      <hr>
      【题干】：<div v-html="questionDetail.question" style="color:blue"></div>
      <div v-if="questionDetail.questionType!=='3'">
        <div style="padding-bottom:5px">{{questionDetail.questionType|tx}} 选项：（以下选中的选项为正确答案）</div>
        <div v-for="item in questionDetail.options" :key="item.code" style="padding:8px 0">
          <el-radio v-if="questionDetail.questionType==='1'" :value="item.isRight" :label="1">{{item.title}}</el-radio>
          <el-checkbox v-if="questionDetail.questionType==='2'" :value="item.isRight?true:false" >{{item.title}}</el-checkbox>
        </div>
      </div>
      <hr>
      【参考答案】：<el-button type="danger" size="small" @click="preivewVideo()">视频答案预览</el-button>
      <div class="video" v-show="play">
        <video ref="video" :src="questionDetail.videoURL" controls style="width:80%" v-viderror="'https://v-cdn.zjol.com.cn/277003.mp4'"></video>
      </div>
      <hr>
      【答案解析】：<div style="display:inline-block" v-html="questionDetail.answer"></div>
      <hr>
      【题目备注】：{{questionDetail.remarks}}
      <div slot="footer">
        <el-button type="primary" @click="close">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { detail } from '../../api/hmmm/questions'
import { questionType } from '../../api/hmmm/constants'
// const cityOptions = ['上海', '北京', '广州', '深圳']
export default {
  props: {
    currentid: {
      type: Number
      // required: true
    }
  },

  data () {
    return {
      showDiglog: false,
      questionDetail: {},
      play: false,

      isNext: true
    }
  },
  // computed: {
  //   qs () {
  //     return this.questionTypeList.find(item => item.value === +this.questionDetail.questionType).label
  //   }
  // },
  filters: {
    nd (value) {
      if (value) return questionType.find(item => item.value === +value).label
    },
    tx (value) {
      if (value) return questionType.find(item => item.value === +value).label + '题'
    }
  },
  methods: {
    close () {
      this.showDiglog = false
    },
    show () {
      this.showDiglog = true
    },
    preivewVideo () {
      this.play = true
      this.$refs.video.play()
    },

    async open () {
      console.log(this.currentid)
      const { data } = await detail({ id: this.currentid, isNext: true })
      console.log(data)
      this.questionDetail = data
      // console.log(this.questionDetail)
      // console.log(this.questionDetail.questionType, '请求')
      // console.log(this.questionTypeList, '美剧')
    }
  }
}
</script>

<style scoped lang='less'>
.el-row {
    // margin-bottom: ;
    &:last-child {
      margin-bottom: 0;
    }
    div {
      height: 30px;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
  .color {
    margin: 10px 0;
  }
  </style>
